#include <stdio.h>
#include "dynamicArray.h"
#include <string.h>

typedef struct Person
{
    char name[20];
    int age;
    char sex;
} Person;

void printFunc(void *arg)
{
    Person data = *(Person *)arg;
    printf("age =%d,name =%s,sex=%c\n", data.age, data.name, data.sex);
}

int main()
{
    DynamicArray array;
    dynamicArrayInit(&array, 5); // 初始化

    Person p1;
    p1.age = 25;
    strcpy(p1.name, "zhangsan");
    p1.sex = 'm';

    Person p2;
    p2.age = 26;
    strcpy(p2.name, "lisi");
    p2.sex = 'm';

    Person p3;
    p3.age = 27;
    strcpy(p3.name, "wangwu");
    p3.sex = 'f';

    travelArrayElement(&array, printFunc); // 打印
    // dynamicArrayAppointDataDelete(&array, 2); // 删除指定的值

    dynamicArrayDestroy(&array); // 内存释放
    return 0;
}
